var gulp = require('gulp');
var watch = require('gulp-watch');
var webpack = require('gulp-webpack');
var connect = require("gulp-connect");
var webpackConfig = require('./webpack.config.js');
gulp.task('dist-webpack', function() {
    return gulp
        .src('/')
        .pipe(webpack(webpackConfig))
});
gulp.task('watch', function () {
    gulp.watch(['./dist/app/*.html'], ['html']);
});
//使用connect启动一个Web服务器
gulp.task('connect', function () {
    connect.server({
        root: './dist/app/',
        livereload: true
    });
});

gulp.task('html', function () {
    gulp.src('./www/*.html')
        .pipe(connect.reload());
});

gulp.task('watch', function () {
    gulp.watch(['./dist/app/*.html'], ['html']);
});

gulp.task('dist-client', function() {
    return gulp.src('src/app/**')
        .pipe(gulp.dest('dist/app'));
});

gulp.task("default",['dist-client',"dist-webpack","connect","watch"]);